/*
 * Created on May 31, 2005
 *
 */
package com.erclab.internal.xpresso.repositories;

import java.util.HashMap;
import java.util.Properties;

import com.erclab.internal.xpresso.exceptions.RepositoryException;
import com.erclab.internal.xpresso.dataAccess.*;

/**
 * @author Enrique Rodriguez.
 *
 */
public abstract class Repository {

	protected Properties properties;
	protected Object repositoryDS;
	protected DAOFactory daoFactory;
	protected HashMap dataSources;

	public abstract void setup() throws RepositoryException;
	public abstract DAOFactory getDaoFactory();
	public abstract ApplicationDataSource getApplicationDataSource(int idDataSource);

	public Object getRepositoryDataSource(){
		return repositoryDS;
	}
	
	public boolean isConfigObject(String objectName){
		return objectName.endsWith(".config");
	}

	public Object getRepositoryDataSource(String objectName){
		if (isConfigObject(objectName)){
			return ((ApplicationDataSource)dataSources.get("1")).getTheDataSource();
		} else {
			return repositoryDS;			
		}
	}

	public HashMap getDataSources() {
		return dataSources;
	}

}
